const list = [
    {
        "id": 1,
        "parentId": null,
        "name": "订单",
        "router": "/order",
        "perms": "",
        "type": 0,
        "icon": "eye",
        "orderNum": 0,
        "viewPath": "",
        "keepAlive": false,
        "isShow": true
    },
    {
        "id": 2,
        "parentId": "1",
        "name": "订单",
        "router": "/orderlist",
        "perms": "",
        "type": 1,
        "icon": "eye",
        "orderNum": 0,
        "viewPath": "/views/order/orderlist.vue",
        "keepAlive": true,
        "isShow": true
    },
    {
        "id": 3,
        "parentId": "1",
        "name": "结算中心",
        "router": "/ordersettlement",
        "perms": "",
        "type": 1,
        "icon": "eye",
        "orderNum": 1,
        "viewPath": "/views/order/center.vue",
        "keepAlive": true,
        "isShow": true
    },
    {
        "id": 4,
        "parentId": null,
        "name": "小说",
        "router": "/novel",
        "perms": "",
        "type": 0,
        "icon": "eye",
        "orderNum": 0,
        "viewPath": "",
        "keepAlive": true,
        "isShow": true
    },
    {
        "id": 5,
        "parentId": null,
        "name": "代理",
        "router": "/agent",
        "perms": "",
        "type": 0,
        "icon": "eye",
        "orderNum": 0,
        "viewPath": "",
        "keepAlive": false,
        "isShow": true
    },
    {
        "id": 6,
        "parentId": null,
        "name": "客户信息",
        "router": "/userinfo",
        "perms": "",
        "type": 0,
        "icon": "eye",
        "orderNum": 0,
        "viewPath": "",
        "keepAlive": false,
        "isShow": true
    },
    {
        "id": 7,
        "parentId": "4",
        "name": "添加小说",
        "router": "/add",
        "perms": "",
        "type": 1,
        "icon": "eye",
        "orderNum": 0,
        "viewPath": "/views/noval/add.vue",
        "keepAlive": false,
        "isShow": true
    },
    {
        "id": 8,
        "parentId": "4",
        "name": "小说列表",
        "router": "/getnovel",
        "perms": "",
        "type": 1,
        "icon": "eye",
        "orderNum": 0,
        "viewPath": "/views/noval/getnovel.vue",
        "keepAlive": false,
        "isShow": true
    },
    {
        "id": 9,
        "parentId": "5",
        "name": "添加代理",
        "router": "/add",
        "perms": "",
        "type": 1,
        "icon": "eye",
        "orderNum": 0,
        "viewPath": "/views/agent/add.vue",
        "keepAlive": false,
        "isShow": true
    },
    {
        "id": 10,
        "parentId": "5",
        "name": "代理",
        "router": "/agentlist",
        "perms": "",
        "type": 1,
        "icon": "eye",
        "orderNum": 0,
        "viewPath": "/views/agent/agentlist.vue",
        "keepAlive": false,
        "isShow": true
    },
    {
        "id": 11,
        "parentId": "6",
        "name": "用户",
        "router": "/userinfolist",
        "perms": "",
        "type": 1,
        "icon": "eye",
        "orderNum": 0,
        "viewPath": "/views/user/user.vue",
        "keepAlive": false,
        "isShow": true
    },
    {
        "id": 12,
        "parentId": "6",
        "name": "账单地址",
        "router": "/userinfo",
        "perms": "",
        "type": 1,
        "icon": "eye",
        "orderNum": 0,
        "viewPath": "/views/user/user.vue",
        "keepAlive": false,
        "isShow": true
    },
    {
        "id": 13,
        "parentId": null,
        "name": "推广页面",
        "router": "/extension",
        "perms": "",
        "type": 0,
        "icon": "eye",
        "orderNum": 0,
        "viewPath": "",
        "keepAlive": false,
        "isShow": true
    },
    {
        "id": 14,
        "parentId": "13",
        "name": "商场首页",
        "router": "/mallindex",
        "perms": "",
        "type": 1,
        "icon": "eye",
        "orderNum": 0,
        "viewPath": "/views/extension/index.vue",
        "keepAlive": false,
        "isShow": true
    },
    {
        "id": 15,
        "parentId": "4",
        "name": "追加章节",
        "router": "/addpart",
        "perms": "",
        "type": 0,
        "icon": "eye",
        "orderNum": 0,
        "viewPath": "/views/noval/addpart.vue",
        "keepAlive": true,
        "isShow": true
    }
]




const route = list.map(v => {
    return {
        id: v.id,
        parentId: v.parentId,  // 是谁的儿子
        path: v.router,
        component: v.viewPath,
        meta: { title: v.name, icon: v.icon },
    }
})


route.forEach(v => {
    v.children = route.filter(e => v.id == e.parentId)
})



console.log(route.filter(v => !v.parentId));